//
//  PMineResumeWorkInfoModel.m
//  Btpin
//
//  Created by Vic on 2019/3/24.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "PMineResumeWorkInfoModel.h"

@implementation PMineResumeWorkInfoModel

- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
    self.info_id = [UIToolsControl dataAnalysis:keyedValues[@"info_id"]];
    self.start_date = [UIToolsControl dataAnalysis:keyedValues[@"start_date"]];
    if (keyedValues[@"end_date"] && [keyedValues[@"end_date"] length]) {
        self.end_date = [UIToolsControl dataAnalysis:keyedValues[@"end_date"]];
    } else {
        self.end_date = @"至今";
    }
    self.company_name = [UIToolsControl dataAnalysis:keyedValues[@"company_name"]];
    self.job_name = [UIToolsControl dataAnalysis:keyedValues[@"job_name"]];
    self.has_img = [UIToolsControl dataAnalysis:keyedValues[@"has_img"]];
    
    self.achievements = [UIToolsControl dataAnalysis:keyedValues[@"achievements"]];
    
    self.desc = [UIToolsControl dataAnalysis:keyedValues[@"desc"]];
    self.descHeight = 0;
    if (self.desc && self.desc.length) {
        self.descHeight = [UIToolsControl textHeightWithLineSpacing:self.desc size:CGSizeMake(WIDTH-60*Scale, MAXFLOAT) font:Font_13]+1;
    }
    
    self.imagesArray = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"evidence"] && [keyedValues[@"evidence"] count]) {
        for (NSDictionary *dic in keyedValues[@"evidence"]) {
            ImageModel *model = [[ImageModel alloc] init];
            [model setValuesForKeysWithDictionary:dic];
            [self.imagesArray addObject:model];
        }
    }
    self.images = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"images"] && [keyedValues[@"images"] count]) {
        for (NSDictionary *dic in keyedValues[@"images"]) {
            ImageModel *model = [[ImageModel alloc] init];
            [model setValuesForKeysWithDictionary:dic];
            [self.images addObject:model];
        }
    }
    
    CGFloat imgHeight = 0;
    self.imgs = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"imgs"] && [keyedValues[@"imgs"] count]) {
        for (NSString *str in keyedValues[@"imgs"]) {
            [self.imgs addObject:str];
        }
        imgHeight = 80*Scale;
    }
    
    self.allHeightOfCompanyLook = 65*Scale+self.descHeight+imgHeight;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (id)copyWithZone:(NSZone *)zone {
    PMineResumeWorkInfoModel *model = [[[self class] allocWithZone:zone] init];
    model.info_id = self.info_id;
    model.start_date = self.start_date;
    model.end_date = self.end_date;
    model.company_name = self.company_name;
    model.job_name = self.job_name;
    model.has_img = self.has_img;
    model.achievements = self.achievements;
    
    model.desc = self.desc;
    model.descHeight = self.descHeight;
    model.allHeightOfCompanyLook = self.allHeightOfCompanyLook;
    
    model.imagesArray = [NSMutableArray arrayWithCapacity:0];
    if (self.imagesArray && self.imagesArray.count) {
        for (ImageModel *tempModel in self.imagesArray) {
            [model.imagesArray addObject:[tempModel copy]];
        }
    }
    
    model.images = [NSMutableArray arrayWithCapacity:0];
    if (self.images && self.images.count) {
        for (ImageModel *tempModel in self.images) {
            [model.images addObject:[tempModel copy]];
        }
    }
    
    model.imgs = [NSMutableArray arrayWithCapacity:0];
    if (self.imgs && self.imgs.count) {
        [model.imgs addObjectsFromArray:self.imgs];
    }
    
    return model;
}

@end
